﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Showroom.BLL;

namespace ShowroomMobile.Controls
{
    public partial class SlideProduct : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                View_ListProducts cProds;
                string cacheKey = "ListProducts_" + Utilities.GetKeySetting("ArrivalProductID");
                if (Cache[cacheKey] == null)
                {
                    int CategoryID = Convert.ToInt32(Utilities.GetKeySetting("ArrivalProductID"));
                    cProds = View_ListProducts.GetListByCategoryID(CategoryID);
                    //Cache
                    Cache.Add(cacheKey, cProds, null, System.DateTime.Now.AddHours(Convert.ToInt32(Utilities.GetKeySetting("CacheTimeOut"))), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null);
                }
                else
                {
                    cProds = (View_ListProducts)Cache[cacheKey];
                }
                cProds.Filter = string.Empty;
                cProds.Rewind();
                rptSlideProduct.DataSource = cProds.DefaultView;
                rptSlideProduct.DataBind();
            }
        }
    }
}